package com.xthink.web.controller;

import com.xthink.common.vo.iPackage.CustomPackagePageVo;
import com.xthink.common.vo.iPackage.InsertCustomSpecs;
import com.xthink.common.vo.iPackage.LikeCustomPackage;
import com.xthink.common.vo.iPackage.NewCustomPackageVo;
import com.xthink.common.result.AjaxResult;
import com.xthink.web.service.CustomPackageHistoryService;
import com.xthink.web.service.CustomSpecsHistoryService;
import com.xthink.web.service.PackageService;
import com.xthink.web.service.PackageSpecsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/customPackage")
public class CustomPackageController {

    @Autowired
    private PackageService packageService;

    @Autowired
    private PackageSpecsService packageSpecsService;

    @Autowired
    private CustomPackageHistoryService customPackageHistoryService;

    @Autowired
    private CustomSpecsHistoryService customSpecsHistoryService;

    //新建自定义套餐
    @PostMapping("/newCustomPackage")
    public AjaxResult newCustomPackage(@RequestBody NewCustomPackageVo newCustomPackageVo){
        return packageService.newCustomPackage(newCustomPackageVo);
    }

    //自定义套餐分页查询
    @PostMapping("/customPackagePage")
    public AjaxResult customPackagePage(@RequestBody CustomPackagePageVo customPackagePageVo){
        return packageService.customPackagePage(customPackagePageVo);
    }

    //自定义套餐上架
    @GetMapping("/customPackagePutOn/{ids}")
    public AjaxResult customPackagePutOn(@PathVariable("ids") Integer[] ids){
        return packageService.customPackagePutOn(ids);
    }

    //自定义套餐下架
    @GetMapping("/customPackageOff/{ids}")
    public AjaxResult customPackageOff(@PathVariable("ids") Integer[] ids){
        return packageService.customPackageOff(ids);
    }

    //删除自定义套餐
    @GetMapping("/customPackageDelete/{ids}")
    public AjaxResult customPackageDelete(@PathVariable("ids")Integer[] ids){
        return packageService.customPackageDelete(ids);
    }

    //自定义套餐模糊搜索
    @PostMapping("/customPackageLike")
    public AjaxResult customPackageLike(@RequestBody LikeCustomPackage likeCustomPackage){
        return packageService.customPackageLike(likeCustomPackage);
    }

    //自定义套餐详情
    @GetMapping("/customPackageDetails/{id}")
    public AjaxResult customPackageDetails(@PathVariable("id") Integer id){
        return packageService.customPackageDetails(id);
    }

    //自定义套餐规格详情
    @GetMapping("/customPackageSpecsDetails/{id}")
    public  AjaxResult customPackageSpecsDetails(@PathVariable("id") Integer id){
        return packageSpecsService.customPackageSpecsDetails(id);
    }

    //自定义套餐规格上架
    @GetMapping("/customPackageSpecsPutOn/{ids}]")
    public AjaxResult customPackageSpecsPutOn(@PathVariable("ids") Integer[] ids){
        return packageSpecsService.customPackageSpecsPutOn(ids);
    }

    //自定义套餐规格下架
    @GetMapping("/customPackageSpecsOff/{ids}]")
    public AjaxResult customPackageSpecsOff(@PathVariable("ids") Integer[] ids){
        return packageSpecsService.customPackageSpecsOff(ids);
    }

    //修改价格自定义套餐规格价格
    @GetMapping("/customPackageSpecsUpdatePrice/{id}/{price}")
    public AjaxResult customPackageSpecsUpdatePrice(@PathVariable("id") Integer id,@PathVariable("price") Double price){
        return packageSpecsService.customPackageSpecsUpdatePrice(id,price);
    }

    //新增自定义套餐规格
    @PostMapping("/InsertCustomSpecs")
    private AjaxResult insertCustomSpecs(@RequestBody InsertCustomSpecs insertCustomSpecs){
        return packageSpecsService.insertCustomSpecs(insertCustomSpecs);
    }

    //修改自定义套餐单价
    @GetMapping("/customPackageUpdatePrice/{id}/{price}")
    public AjaxResult customPackageUpdatePrice(@PathVariable("id") Integer id,@PathVariable("price") Double price){
        return packageService.customPackageUpdatePrice(id,price);
    }

    //查询自定义套餐单价历史价格
    @PostMapping("/listCustomPackagePrice")
    public AjaxResult listCustomPackagePrice(@RequestBody CustomPackagePageVo customPackagePageVo){
        return customPackageHistoryService.listCustomPackagePrice(customPackagePageVo);
    }

    //查询自定义套餐规格历史价格
    @PostMapping("/listCustomSpecsPrice")
    public AjaxResult listCustomSpecsPrice(@RequestBody CustomPackagePageVo customPackagePageVo){
        return customSpecsHistoryService.listCustomSpecsPrice(customPackagePageVo);
    }
}
